package com.sale.goods.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sale.common.core.utils.StringUtils;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import com.sale.goods.domain.dto.GoodsCollectionDto;
import com.sale.goods.domain.dto.GoodsCostDto;
import com.sale.goods.domain.vo.GoodsCollectionVo;
import com.sale.goods.domain.vo.GoodsCostVo;
import com.sale.goods.mapper.GoodsCostMapper;
import com.sale.goods.service.IGoodsCostService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Description 成本调整
 * @Date 23-08-08
 * @Author hl
 **/
@RequiredArgsConstructor
@Service
public class GoodsCostServiceImpl implements IGoodsCostService {

    private final GoodsCostMapper goodsCostMapper;

    /**
     * 分页查询成本调整
     *
     * @param goodsCostVo,pageQuery
     * @return 成本调整
     */
    @Override
    public TableDataInfo<GoodsCostDto> selectCostList(GoodsCostVo goodsCostVo, PageQuery pageQuery) {
        Page<GoodsCostDto> page = goodsCostMapper.selectCostList(pageQuery.build(), this.buildQueryWrapper(goodsCostVo));
        return TableDataInfo.build(page);
    }

    private Wrapper<GoodsCostVo> buildQueryWrapper(GoodsCostVo goodsCostVo) {
        Map<String, Object> params = goodsCostVo.getParams();
        QueryWrapper<GoodsCostVo> wrapper = Wrappers.query();
        wrapper
            .eq(ObjectUtil.isNotNull(goodsCostVo.getCostCode()), "cost_code", goodsCostVo.getCostCode())
            .eq(StringUtils.isNotBlank(goodsCostVo.getCostStatus()), "cost_status", goodsCostVo.getCostStatus()).between(params.get("beginTime") != null && params.get("endTime") != null,
                "create_time", params.get("beginTime"), params.get("endTime"));
        return wrapper;
    }

    @Override
    public int insertCost(GoodsCostVo goodsCostVo) {
        return 0;
    }

    @Override
    public Object selectCostById(long costId) {
        return null;
    }

    @Override
    public int deleteCostById(Long costId) {
        return 0;
    }

    @Override
    public int updateCostEdit(GoodsCostVo goodsCostVo) {
        return 0;
    }

    @Override
    public int submitReview(Long costId) {
        return 0;
    }

    @Override
    public int deleteReview(Long costId) {
        return 0;
    }

    @Override
    public int goodSExamineReview(GoodsCostVo goodsCostVo) {
        return 0;
    }
}
